package com.ysh.ssm.controller.advice;

import com.ysh.ssm.dto.R;
import com.ysh.ssm.exceptions.MyBaseException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 袁胜虎 on 2022/8/31 22:07
 */
@RestControllerAdvice
public class MyControllerAdvice {
    /**
     * 处理我们自定义异常的处理器
     * @param exception
     * @return
     */
    @ExceptionHandler(MyBaseException.class)
public R processMyBaseException(MyBaseException exception) {
    exception.printStackTrace();
    return  R.getResult(exception.getCode(),exception.getMessage());
    }
}
